import React, { Component } from 'react';
import FileUpload from './react-fileupload';

class FileUploader extends Component{
	render(){
		const options={
			baseUrl        :'/manage/product/upload.do',
			fileFieldName  : 'upload_file',
			dataTpe        : 'json',
			chooseAndUpload: true,
			uploadSuccess  : (res)=>{this.props.onSuccess(res.data)},
			uploadError    : (err)=> {this.props.onError(err.message || '上传图片出错了')}
		}
	return (
		<FileUpload options={options}>
			<button ref="chooseAndUpload">请选择图片</button>
		</FileUpload>
		);
	}	        
}

export default FileUploader;
